import request from "@/utils/request.js"

// 登录接口调用函数
export const userLoginService = (loginData) => {
    return request.post('/user/login', loginData)
}

// 我的登录接口
export const usermainLoginService = (loginData) => {
    return request.post('/usermain/login', loginData)
}

//我的注册接口
export const usermainregisterService = (registerdata) =>{
    return request.post('/usermain/register',registerdata)
}

// @/api/user.js


// 获取当前登录用户信息
export const currentUserService = () => {
    return request.get('/user/currentUser')
}
export const currentUsermainService = () => {
    return request.get('/usermain/currentUser')
}

// 获取所有用户信息
export const allUserService = () => {
    return request.get('/user/userList')
}
export const allUsermainService = () => {
    return request.get('/usermain/userList')
}

// 分页查询
export const pageListService = (pageParam) => {
    //console.log(pageParam);
    return request.get('/user/pageList', {params: pageParam})
}
export const pageListmainService = (pageParam) => {
    console.log(pageParam);
    console.log(pageParam.page)
    return request.get('/usermain/pageList', {params: pageParam})
}
export const customerpageListService = (pageParam) =>{
    return request.get('/customer/pageList',{params:pageParam})
}
export const businesspageListService = (pageParam) =>{
    console.log(pageParam + " test ");
    return request.get('/business/pageList',{params:pageParam})
}

// 新增用户
export const addUserService = (addData) => {
    return request.post('/user/add', addData)
}
export const addUsermainService = (addData) => {
    return request.post('/usermain/register', addData)
}
export const customeraddUserService = (addData) => {
    return request.post('/customer/add', addData)
}
export const businessaddService = (addData) => {
    return request.post('/business/add', addData)
}

// 根据id获取用户信息
export const getUserById = (id) => {
    return request.get('/user/getuserById', {params: id})
}
export const getUsermainById = (id) => {
    return request.get('/usermain/getuserById', {params: id})
}
export const customergetUserById = (id) => {
    return request.get('/customer/getuserById', {params: id})
}
export const businessgetByIdService = (id) => {
    return request.get('/business/getuserById', {params: id})
}
// 修改用户信息
export const updateUserService = (data) => {
    return request.put('/user/update', data)
}
export const updateUsermainService = (data) => {
    return request.put('/usermain/update', data)
}
export const customerupdateUserService = (data) => {
    
    return request.put('/customer/update', data)
}
export const businessupdateService = (data) => {
    
    return request.put('/business/update', data)
}
// 删除用户
export const deleteByIdService = (id) => {
    console.log("deleteRequestid:", id)
    return request.delete('/user/delete/' + id)
}
export const deleteByIdmainService = (userId) => {
    console.log("deleteRequestid:", userId)
    return request.delete('/usermain/delete/' + userId)
}
export const customerdeleteByIdService = (id) => {
    console.log("deleteRequestid:", id)
    return request.delete('/customer/delete/' + id)
}
export const businessdeleteByIdService = (id) => {
    console.log("deleteRequestid:", id)
    return request.delete('/business/delete/' + id)
}

//验证是否是管理员
export const permission = () =>{
    console.log("find is  permisson")
    return request.get('/usermain/permission')
}


// 以下是删除找回功能
export const getDeletedUsersService = (pageParam) =>{
    return request.get('/usermain/pagerecovery' , {params:pageParam})
}

export const restoreUserService = (id) => {
    return request.get(`/usermain/restore/` + id);
};
  
  export const permanentlyDeleteUserService = (id) => {
    return request.get(`/usermain/deleteforever/${id}`);
};
  



// 退出登录
export function logoutService() {
  return request({
    url: '/usermain/logout',
    method: 'post'
  })
}
